<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>

	<title>GESTOR INCIDENCIAS</title>
	<link rel="stylesheet" type="text/css" href="css/style.css">
	<link rel="stylesheet" type="text/css" href="css/menu.css">
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.js"></script>
	
	<script src="js/menu.js"></script>
	<script src="js/comprobar_datos.js"></script>

</head>
<body>

<?php
require('php/cabecera.php');
?>
<script>
	
		function getAñadirdisp(){
		
			var nombre=document.getElementById("nombre");
			
			var xmlhttp;
                if (window.XMLHttpRequest)
                {// code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlhttp=new XMLHttpRequest();
                }
                else
                 {// code for IE6, IE5
                     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                 }
            xmlhttp.onreadystatechange=function()
             {
                if (xmlhttp.readyState==4 && xmlhttp.status==200)
                 {
				  	
					document.getElementById("aviso").innerHTML=xmlhttp.responseText;    
					setInterval('location.reload()',2000);           
                 }
				     	
			   }
        	
            xmlhttp.open("GET","php/insertarnuevotipodisp.php?nombre="+nombre.value,true);
            xmlhttp.send();
		
		}
	
	
	</script>
	<script>
	function comprobarDis(){
	var nombre = document.getElementById("nombre");
	if (vacio(nombre) == true){
        nombre.className = "error";
		document.getElementById("aviso").innerHTML="<span style='color:red'>El campo está vacío</span>"; 
		setInterval('location.reload()',2000); 
    }else{
		nombre.className = " ";
		getAñadirdisp();
	}
	
}
	</script>
	<script>
			(function($){
				
				//cache nav
				var nav = $("#topNav");
				
				//add indicator and hovers to submenu parents
				nav.find("li").each(function() {
					if ($(this).find("ul").length > 0) {
						/*$("<span>").text("^").appendTo($(this).children(":first"));*/

						//show subnav on hover
						$(this).mouseenter(function() {
							$(this).find("ul").stop(true, true).slideDown();
						});
						
						//hide submenus on exit
						$(this).mouseleave(function() {
							$(this).find("ul").stop(true, true).slideUp();
						});
					}
				});
			})(jQuery);
		</script>

<div id="contenido">
<?php
require('php/menuvotrasopciones.php');
?>
	
		<div id="principal">
			<h2><?php echo $xtitutidospo;?></h2>
			<div id="aulas">
				<div id="creardis">
					<h3><?php echo $xinstipo;?></h3>
					<form>
						<?php echo $xnombdisp;?>: 
						<input type="text" id="nombre" maxlength="20"><br />
						<br />
						<input type="button" id="boton" value="<?php echo $xprovana;?>" onClick="comprobarDis()"><br />
					</form>
					<br />
					<div id="aviso">
					</div>
				</div>
				<div id="listadis">
				<?php
			
					require('php/conexionbd.php');
			
					echo '<form method="post" action="php/eliminartipodisp.php">
					<table>
					<tr>';
						
					$res=mysql_query("select * from tipo_dispositivo",$con);
					$cont=0;
					$x=0;					
					while($row = mysql_fetch_array($res)){
						$id_tipo=$row['id_tipo'];
						$tipo=$row['tipo'];
						if($x==0){
							echo "<tr>";
						}
						if($cont%2==0){
						echo "<th class='fila_par'><input type='checkbox' name='casilla[]' value='".$id_tipo."'></th>";
						echo "<th class='fila_par'>$tipo</th>";
						}else{
							echo "<th class='fila_impar'><input type='checkbox' name='casilla[]' value='".$id_tipo."'></th>";
							echo "<th class='fila_impar'>$tipo</th>";
						}
						$x++;
						if($x==4){
							$x=0;
							echo "</tr>";
						}
						$cont++;
					}
							
						
					echo "</tr>";
					
					echo "</table>";
					echo "<input type='submit' value='$xelimest' />";
					echo '</form>';
				?>
				</div>
			</div>
		</div>
</div>
	
	<div id="pie">
		<?php 
		include("pie.php");
		?>
	</div>
	
</body>
</html>